#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 1e6 + 10;
const ll p = 1e4;
int n, f[N] = { 0,1,2 }, k[N] = { 0,0,1 };

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 3; i <= n; i++) {
		f[i] = (f[i - 1] + f[i - 2] + k[i - 1] * 2) % p;
		k[i] = (f[i - 2] + k[i - 1]) % p;
	}
	cout << f[n] << endl;
	return 0;
}